package cn.layfolk.uaa.controller;


import cn.layfolk.daimao.vo.respvo.ResponseVo;
import cn.layfolk.uaa.service.TUserService;
import cn.layfolk.uaa.vo.UserLoginInDto;
import cn.layfolk.uaa.vo.UserLoginOutDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.UnsupportedEncodingException;

/**
 *
 * 账号管理，登录，退出，改密码等。
 */
@RestController
@Api(tags = "账号管理")
@RequestMapping("/account")
@Validated
public class TUserController {


    @Autowired
    private TUserService userService;

    /**
     * 登录
     *
     * @param inDto
     * @return
     */
    @ApiOperation("登录")
    @PostMapping("clientLogin")
    public ResponseVo<UserLoginOutDto> login(@RequestBody @Valid UserLoginInDto inDto) throws UnsupportedEncodingException {
        return userService.login(inDto);
    }

    /**
     * 登出
     * @return
     * @throws UnsupportedEncodingException
     */
    @ApiOperation("登出")
    @GetMapping("clientLogout")
    public ResponseVo logout() throws UnsupportedEncodingException {
        return userService.logout();
    }

}

